Skip to main content

CircleCI

Follow the steps below to send test results from CircleCI to BuildPulse. CircleCI uploads through the BuildPulse upload API with an API token.

If you'd like help at any step, please get in touch.

1. Create an API key.

In BuildPulse, open Organization Settings, then API Keys, and click Create API Key. The key starts with bp_ and is shown once.

In CircleCI, open Project Settings, then Environment Variables, and add it as BUILDPULSE_API_TOKEN. [docs]

2. Copy the upload script for your repository.

In BuildPulse, open the repository and go to its Setup tab. Under "Wire BuildPulse into your CI pipeline", pick CircleCI and your test framework. The page shows the script below with your repository ID filled in.

For a repository hosted on GitHub, install the BuildPulse GitHub App on it first, so that the repository exists in BuildPulse.

Save the script in your repository, for example as .circleci/buildpulse-upload.sh. Replace <your-repository-id> with the ID from the Setup tab, and set RESULTS_GLOB to where your test framework writes its JUnit XML.

set -euo pipefail

REPO_ID="<your-repository-id>"
RESULTS_GLOB="junit.xml"

# Assemble the archive.
rm -rf _bp && mkdir -p _bp/test-results _bp/coverage
cp $RESULTS_GLOB _bp/test-results/ 2>/dev/null || cp -r $RESULTS_GLOB/. _bp/test-results/

cat > _bp/buildpulse.yml <<YML
version: "1.0"
source: buildpulse-action
timestamp: $(date -u +%Y-%m-%dT%H:%M:%S.000Z)
git:
commit: $(git rev-parse HEAD)
message: "$(git log -1 --pretty=%s | sed 's/"/\\"/g')"
branch: $(git rev-parse --abbrev-ref HEAD)
tree: $(git rev-parse 'HEAD^{tree}')
ci:
provider: circleci
build_id: "$CIRCLE_WORKFLOW_ID"
build_number: "$CIRCLE_BUILD_NUM"
build_url: "$CIRCLE_BUILD_URL"
job: "$CIRCLE_JOB"
YML

tar -C _bp -czf buildpulse.tar.gz buildpulse.yml test-results coverage

# 1. Ask for a signed upload URL (expires in 5 minutes).
RESP="$(curl -fsS -X POST https://buildpulse.io/api/test-results/upload-url \
-H "Authorization: Bearer $BUILDPULSE_API_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"repositoryId\":\"$REPO_ID\"}")"

URL="$(printf '%s' "$RESP" | sed -n 's/.*"uploadUrl":"\([^"]*\)".*/\1/p')"
[ -n "$URL" ] || { echo "upload-url failed: $RESP"; exit 1; }

# 2. Upload the archive.
curl -fsS -X PUT "$URL" -H "Content-Type: application/gzip" --data-binary @buildpulse.tar.gz

echo "BuildPulse upload complete."

3. Run the script after your tests in .circleci/config.yml.

Use when: always so that the step also runs when tests fail, which is where flaky tests show up.

      - run:
name: Upload test results to BuildPulse
when: always
command: bash .circleci/buildpulse-upload.sh

Keeping the script in its own file avoids escaping: CircleCI reads << inside config.yml as the start of a pipeline parameter.

4. Commit those changes.

Push your branch and check the "Upload test results to BuildPulse" step in the job. It ends with BuildPulse upload complete. Within a few minutes the repository's Test Runs tab in BuildPulse shows the run.

See Other CI Providers for coverage files, tags and notes on the upload format.

Using the workshop64/buildpulse orb?

The orb authenticates with an access key ID and secret access key plus numeric account and repository IDs. New accounts are not issued access keys, so new setups should follow the steps above. If you already use the orb and have questions about moving, email support@buildpulse.io.

To run CircleCI jobs on BuildPulse machines, which is a separate product from test reporting, see CircleCI and Semaphore on BuildPulse runners.